package com.gmq.mianshi.designModel.observe;

import com.gmq.mianshi.designModel.observe.observer.ConcreteObserver;
import com.gmq.mianshi.designModel.observe.observer.Observer;
import com.gmq.mianshi.designModel.observe.subject.ConcreteSubject;
import com.gmq.mianshi.designModel.observe.subject.Subject;

/**
 * @author gmq
 * @email 2628931@qq.com
 * @date 2017/11/27 14:46
 */
public class Test {

    public static void main(String[] args) {
        // 建立观察者
        Observer watcher = new ConcreteObserver();
        // 被观察对象，主题
        Subject watched = new ConcreteSubject();
        // 被观察对象添加观察者
        watched.registerObserver(watcher);
        // 当被观察对象改变时，通知观察者
        watched.notifyObserver();
    }
}
